<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Class CreateInvoicesTable.
 */
class CreateInvoicesTable extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('invoices', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->comment('用户id');
            $table->string('order_code',64)->comment('订单编号');
            $table->tinyInteger('invoice_message')->default(1)->comment('发票信息 1、个人 2、企业');
            $table->tinyInteger('invoice_type')->default(1)->comment('增值税发票类型 1、普通发票 2、专用发票');
            $table->string('invoice_title',64)->comment('寄送发票抬头');
            $table->string('tax_code',64)->comment('税号');
            $table->string('invoice_address',64)->comment('开票地址');
            $table->string('invoice_tel',64)->comment('开票电话');
            $table->string('invoice_bank',64)->comment('开票开户银行');
            $table->string('invoice_account',64)->comment('开票银行账户');
            $table->integer('shipping_id')->nullable()->comment('快递方式id');
            $table->string('shipping_name',64)->nullable()->comment('快递方式名称');
            $table->decimal('shipping_cost',10,2)->nullable()->comment('快递费');
            $table->string('courier_number',64)->nullable()->comment('快递单号');
            $table->string('post_address', 64)->nullable()->comment('寄送地址');
            $table->string('post_contacts',64)->nullable()->comment('联系人');
            $table->string('post_tel',32)->nullable()->comment('快递联系人手机号');
            $table->tinyInteger('invoice_status')->default(1)->comment('发票状态:1未开出，2已开出');
            $table->string('invoice_code',64)->nullable()->comment('发票代码');
            $table->string('invoice_number',64)->nullable()->comment('发票号码');
            $table->decimal('invoice_price',10,2)->nullable()->comment('开票金额');
            $table->timestamp('open_invoice_at')->nullable()->comment('开票时间');
            $table->string('open_invoice_user',64)->nullable()->comment('开票操作人');
            $table->string('create_user',50)->nullable()->comment('创建人姓名');
            $table->string('update_user',50)->nullable()->comment('修改人姓名');
            $table->string('remark')->nullable()->comment('备注');

            $table->timestamps();
            $table->softDeletes();
            $table->index('order_code');
            $table->index('user_id');
            $table->engine = 'InnoDB';
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('invoices');
	}
}
